Xbasic

usps_citystate_from_zip Function

Syntax

CityState as P = usps_citystate_from_zip(C zip5 )

Arguments

CityState

A pointer variable with two properties City and State.

City

The name of the city containing the specified ZIP code.

State

The name of the state containing the specified ZIP code.

zip5

A 5 or 9 digit ZIP code. The function truncates 9 digit codes to 5 digits.

Description

Contacts the USPS web site and looks up the city and state for the specified 5 digit zip code.

Discussion

The USPS_CityState_From_ZIP() contacts the USPS web site and looks up the city and state containing the specified ZIP code. It then returns the state and city that contains the specified ZIP code. Note : Use of this function requires an active Internet connection. ZIP codes are used by the US Postal Service (USPS) for addressing mail in the United States.

Example

? usps_citystate_from_zip("01803") 
= city = "BURLINGTON" 
state = "MA" 

? usps_citystate_from_zip("12345") 
= city = "SCHENECTADY" 
state = "NY"